package com.example.spring_mybatis.mapper_blog;

import com.example.spring_mybatis.model_blog.PersonInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/10/12
 * Time: 23:23
 */
@Mapper
public interface BlogMapper {

    @Select("select * from blog")
    List<PersonInfo> getPersonInfoAll();

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into blog values (#{id},#{name},#{age})")
    Integer addPerson(PersonInfo person);

    @Update("update blog set name = #{name},age = #{age} where id = #{id}")
    Integer updatePerson(PersonInfo personInfo);

    @Delete("delete from blog where id = #{id}")
    Integer deletePerson(Integer id);

    //@Param
    @Update("update blog set name = #{name},age = #{age} where id = #{id}")
    Integer updatePersonInfo(@Param("id") Integer userId,@Param("name") String userName,@Param("age") Integer userAge);

    @Select("select * from blog where name = '${name}'")
    List<PersonInfo> test(String name);
}
